
function onDelete(aa){
  $('#modalTable').addClass("modal");
}

function onUpdate(aid){
  $('#modalTable').addClass("modal");
  $('#modalTable').modal('show');
	$.ajax({type : "GET",
		url : _ctx + "/alarm/alarmprop/update/"+aid,							
		success : function(data) {
		var json = eval('(' + data + ')');
		$("[name^='m_']").each(function(index, item){
			$(item).val(json[item.name]);
		});
	}});
}

jQuery(function($) {  
	
	$('html').attr('style','overflow-x:scroll;overflow-y:scroll;');
	
    $("#siteSel").change(function(){
        var url = _ctx + "/alarm/alarmprop/getNe";
        var optionstr = '<option value="0" selected>ALL</option>';
		$.getJSON(url,{sid:$("#siteSel").val()},function(data){
			for (var i=0; i<data.length; i++){
				optionstr = optionstr + "<option value="+data[i].nid+">"+data[i].ip+"</option>";
			}
			$("#neSel").html(optionstr);
		});
    });
    
	
    $("#neSel").change(function(){
        var url = _ctx + "/alarm/alarmprop/getUseCardSlot";
        var optionstr = '<option value="0" selected>ALL</option>';
		$.getJSON(url,{neid:$("#neSel").val()},function(data){
			//var json = eval('(' + data + ')');
			for (var i=0; i<data.length; i++){
				optionstr = optionstr + "<option value="+data[i].cardid+">"+data[i].num+":"+data[i].cardtype+"</option>";
			}
			$("#slotSel").html(optionstr);
		});
    });    
    
    
	$('#btnSubmit').click(function() {
		var frmobj = {};
		$("[name^='m_']").each(function(index, item){
			frmobj[item.name] = $(item).val();
		});		
		var ojbstr = JSON.stringify(frmobj);
		var url = _ctx + "/alarm/alarmprop/update";
		$.ajax({
			type : "POST",
			url : url,
			data : {"jstr":ojbstr}, 
			success : function(data) {
				$('#modalTable').hide();
				if (data == 1) {
					bootbox.confirm("保存成功!", function(result) {
						$('#searchForm').submit();
						$('#modalTable').modal('hide');
					});
				} else {
					bootbox.confirm("保存失败!", function(result) {
						$('#modalTable').modal('hide');
					});
				}
			}
		});
		  $('#modalTable').removeClass("modal");
	});    
    
});